const token = uni.getStorageSync('token') || undefined // 获取token值
const baseUrl = "https://api.shop.eduwork.cn"
console.log('进入了request')

const request = (params) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseUrl + params.url,
			data: params.data,
			method: params.methods,
			header: {
				'Authorization': 'Bearer ' + token
			}
		}).then((response) => {
			let [error, res] = response;
			resolve(res.data);
		}).catch(error => {
			let [err, res] = error;
			reject(err)
		})
	});
}

export default {
	request
}
